Listener rules define how a load balancer routes incoming requests based on conditions such as host headers, paths, HTTP methods, query parameters, and source IP addresses, with actions like forwarding, redirecting, or returning fixed responses [citation:1][citation:2].
Listener rules are a key feature of the Application Load Balancer (ALB). You configure rules for each listener on the load balancer. Each rule consists of a condition and an action [citation:2]. Supported conditions include [citation:1]:
Host header: Route based on the domain name (e.g., api.example.com vs www.example.com).
Path: Route based on the URL path (e.g., /images/* vs /video/*).
HTTP headers: Route based on standard or custom HTTP headers.
HTTP methods: Route based on the HTTP method (e.g., GET vs POST).
Query parameters: Route based on query string parameters.
Source IP CIDR: Route based on the client's IP address range.
Supported actions include [citation:1][citation:2]:
forward: Route the request to a target group.
redirect: Redirect the client to a different URL (e.g., from HTTP to HTTPS).
fixed-response: Return a custom HTTP response (e.g., a 404 page) directly from the load balancer.
authenticate: Authenticate users via Amazon Cognito or an OIDC-compliant IdP.